import { createApp } from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
// import ant from "./utils/ant"
// 引入Ant Design of Vue
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';

// 使每次请求都会带一个/api前缀
axios.defaults.baseURL = '/api'
axios.defaults.withCredentials = true
axios.interceptors.request.use(config => {
  // CSRF Safe Methods: GET, HEAD, OPTIONS, TRACE
  if (!(/^(get|head|options|trace)$/.test(config['method']))) {
    // Carry CSRF token
    config['xsrfCookieName'] = 'csrftoken'
    config['xsrfHeaderName'] = 'X-CSRFToken'
  }
  return config
})


const app = createApp(App);
app.config.productionTip = false;
// 挂载axios到app，在app的每个组件中都可以使用axios发送请求，
// 不需要每次都import一下axios了，直接使用this.axios即可
app.use(VueAxios, axios).use(Antd).mount('#app');
// app.use(VueAxios, axios).mount('#app');

// createApp(App).use(ant).mount('#app')
